import * as THREE from '../../build/three.module.js';

let scene = new THREE.Scene();

/**
 * --==========================-
 * --======构建球体网格模型=======-
 * --==========================-
 */
let geoSphere = new THREE.SphereGeometry(50, 40, 40);
let matSphere = new THREE.MeshLambertMaterial({
  color: 0x0000ff
});
let meshSphere = new THREE.Mesh(geoSphere, matSphere);
meshSphere.translateX(-175);
meshSphere.translateY(100);
meshSphere.translateZ(100);
scene.add(meshSphere);
/* ============================ */
/* ============================ */

/**
 * --==========================-
 * --======构建立方体网格模型=======-
 * --==========================-
 */
let geoBox = new THREE.BoxGeometry(100, 100, 100);
let matBox = new THREE.MeshLambertMaterial({
  color: 0x00ff00
});
let meshBox = new THREE.Mesh(geoBox, matBox);
meshBox.translateY(125);
scene.add(meshBox);
/* ============================ */
/* ============================ */

/**
 * --==========================-
 * --======构建圆柱网格模型=======-
 * --==========================-
 */
let geoCylinder = new THREE.CylinderGeometry(50, 25, 100, 25, 1);
let matCylinder = new THREE.MeshLambertMaterial({
  color: 0xff0000
});
let meshCylinder = new THREE.Mesh(geoCylinder, matCylinder);
meshCylinder.translateY(250);
meshCylinder.translateX(250);
scene.add(meshCylinder);
/* ============================ */
/* ============================ */

/**
 * --==========================-
 * --=====构建正八面体网格模型=====-
 * --==========================-
 */
let geoOctahedron = new THREE.OctahedronGeometry(75);
let matOctahedron = new THREE.MeshLambertMaterial({
  color: 0x00ffff
});
let meshOctahedron = new THREE.Mesh(geoOctahedron, matOctahedron);
meshOctahedron.translateZ(225);
scene.add(meshOctahedron);
/* ============================ */
/* ============================ */

/**
 * --==========================-
 * --====构建正十二面体网格模型====-
 * --==========================-
 */
let geoDodecahedron = new THREE.DodecahedronGeometry(75);
let matDodecahedron = new THREE.MeshLambertMaterial({
  color: 0xff00ff
});
let meshDodecahedron = new THREE.Mesh(geoDodecahedron, matDodecahedron);
meshDodecahedron.translateY(-150);
scene.add(meshDodecahedron);
/* ============================ */
/* ============================ */

/**
 * --==========================-
 * --====构建正二十面体网格模型====-
 * --==========================-
 */
let geoIcosahedron = new THREE.IcosahedronGeometry(75);
let matIcosahedron = new THREE.MeshLambertMaterial({
  color: 0xffff00
});
let meshIcosahedron = new THREE.Mesh(geoIcosahedron, matIcosahedron);
meshIcosahedron.translateY(0);
meshIcosahedron.translateX(225);
scene.add(meshIcosahedron);
/* ============================ */
/* ============================ */

// 插入辅助坐标系
let axesH = new THREE.AxesHelper(200);
scene.add(axesH);

// 光源
let pointL = new THREE.PointLight(0xffffff);
pointL.position.set(400, 300, 200);
scene.add(pointL);
let ambientL = new THREE.AmbientLight(0x444444);
scene.add(ambientL);

// 相机
let width = window.innerWidth,
    height = window.innerHeight,
    k = width / height,
    s = 200;
let camera = new THREE.OrthographicCamera(-s * k, s * k, s, -s, 1, 1000);
camera.position.set(400, 400, 400);
camera.lookAt(scene.position);

// 渲染器
let renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
renderer.setClearColor(0xaaaaaa, 1);

// 插入画布
document.body.appendChild(renderer.domElement);

function render () {
  renderer.render(scene, camera);
}
render();